//
//  main.c
//  简单选择排序
//
//  Created by apple on 2016/12/19.
//  Copyright © 2016年 apple. All rights reserved.
//

#include <stdio.h>
void SelectionSort(int a[],int n)
{
    int i,j,tem;
    int index;
    for(i=0;i<n-1;i++)
    {
        index=i;
        for (j=i+1; j<n; j++)
            if (a[j]<a[index])
                index=j;
                if(i!=index)
                {tem=a[i];a[i]=a[index];a[index]=tem;}
            
        
    }
}
int main()
{
    int a[6]={49,38,66,97,49,26};
    int i;
    SelectionSort(a, 6);
    printf("排序后：");
    for (i=0; i<6; i++)
        printf("%6d  ",a[i]);
        return 0;
    
    
}